dnl # Process this file with autoconf to produce a configure script.
dnl ######################################################################
dnl # File: configure.ac                               Part of The Raven #
dnl #                                                                    #
dnl # Copyright (C) 2011 by Joachim Pileborg <arrow@pileborg.org>.       #
dnl # All rights reserved.                                               #
dnl #                                                                    #
dnl # Redistribution and use in source and binary forms, with or without #
dnl # modification, are permitted provided that the following conditions #
dnl # are met:                                                           #
dnl #                                                                    #
dnl #   o Redistributions of source code must retain the above copyright #
dnl #     notice, this list of conditions and the following disclaimer.  #
dnl #   o Redistributions in binary form must reproduce the above        #
dnl #     copyright notice, this list of conditions and the following    #
dnl #     disclaimer in the documentation and/or other materials         #
dnl #     provided with the distribution.                                #
dnl #   o Neither the name of The Raven nor the names of its contributors#
dnl #     may be used to endorse or promote products derived from this   #
dnl #     software without specific prior written permission.            #
dnl #                                                                    #
dnl # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             #
dnl # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        #
dnl # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           #
dnl # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           #
dnl # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS  #
dnl # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,#
dnl # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,           #
dnl # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR #
dnl # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY       #
dnl # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR     #
dnl # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF #
dnl # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF    #
dnl # SUCH DAMAGE.                                                       #
dnl #                                                                    #
dnl ######################################################################
dnl # Information on the package

AC_INIT(raven, [0.0.0], [raven@pileborg.org], , [http://code.google.com/p/the-raven/])
AC_COPYRIGHT([Parts of the configure script is copyright (C) 2010, Joachim Pileborg <arrow@pileborg.org>])
AC_CONFIG_SRCDIR([src/raven.h])
AC_CONFIG_AUX_DIR([scripts])
AC_CONFIG_HEADERS([src/autoconf.h])
AC_CONFIG_LIBOBJ_DIR([src/libobj])

dnl ######################################################################
dnl # Automake specific checks

AM_INIT_AUTOMAKE

dnl ######################################################################
dnl # Checks for programs

dnl # The actual compiler
AC_PROG_CXX
AC_PROG_CXX_C_O
AC_PROG_CXXCPP

dnl # Set default language to C++
AC_LANG([C++])

dnl # General programs, and their arguments
AC_PROG_RANLIB

AC_REQUIRE_CPP

dnl ######################################################################
dnl # Checks for libraries

# TODO: boost libraries

dnl ######################################################################
dnl # Checks for header files

AC_CHECK_HEADERS([cuchar uchar.h])

# TODO: boost header files

dnl ######################################################################
dnl # Checks for types

AC_TYPE_LONG_LONG_INT
AC_TYPE_MBSTATE_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

AC_CHECK_TYPES([char32_t], [], [], [[#include <cuchar>]])

# TODO: boost types

dnl ######################################################################
dnl # Checks for structures

AC_CHECK_MEMBER([struct stat.st_blksize],
                [AC_DEFINE(HAVE_STRUCT_STAT_ST_BLKSIZE, 1,
                           [Define to 1 if struct stat have a member st_blksize.])],
                [], [[#include <sys/stat.h>]])

dnl ######################################################################
dnl # Checks for compiler characteristics

AC_C_BACKSLASH_A

# TODO: Check for flag: -std=c++0x (or -std=gnu++0x? or check for both?)
# TODO: Check for flag: -pendantic
# TODO: Check for flag: -Wall
# TODO: Check for flag: -Weffc++
# TODO: Check for char escape: \e
# TODO: Check for constant: nullptr
# TODO: Check for: Unicode support (C++0x u'c' and U'c')

dnl ######################################################################
dnl # Checks for library functions

dnl ######################################################################
dnl # Checks for system services

AC_FUNC_STRERROR_R

dnl ######################################################################

# TODO: autoheader templates?

AH_TOP([/* -*- C++ -*- */
#ifndef __AUTOCONF_H__
#define __AUTOCONF_H__ 1
/* *******************************************************************
* File: autoconf.h                                 Part of The Raven *
*                                                                    *
* This file is automaticly generated by the configure script.        *
* All changes to this file may be lost without warning.              *
*                                                                    *
* Parts of this file is copyright (C) 2010 by Joachim Pileborg       *
* <arrow@pileborg.org>. All rights reserved.                         *
*                                                                    *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met:                                                           *
*                                                                    *
*   o Redistributions of source code must retain the above copyright *
*     notice, this list of conditions and the following disclaimer.  *
*   o Redistributions in binary form must reproduce the above        *
*     copyright notice, this list of conditions and the following    *
*     disclaimer in the documentation and/or other materials         *
*     provided with the distribution.                                *
*   o Neither the name of The Raven nor the names of its contributors*
*     may be used to endorse or promote products derived from this   *
*     software without specific prior written permission.            *
*                                                                    *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS  *
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,*
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,           *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY       *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR     *
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF    *
* SUCH DAMAGE.                                                       *
*                                                                    *
******************************************************************* */

])

AH_BOTTOM([
/* **************************************************************** */
#endif /* __AUTOCONF_H__ */
])

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

dnl ######################################################################
